const book = E = {
	page() {
		let _tbody = $('#_tbody');
		$.ajax({
			url: url.path + 'dingdan/onese',
			type: 'get',
			data: {
				uid: "",
				wid: localStorage.getItem("wid")
			},
			dataType: 'json',
			success: function(res) {
				console.log(res);
				if (res.code == 200) {
					_tbody.empty(); // 将容器清空
					let list = res.data;

					$(list).each(function(i, e) {
						if (e.state == 2) {
							state = '待支付';
							let _tds = $(`
							<div class="workorder-card">
								<div class="workorder-status">` + state + `</div>
								<p class="my-1">工单编号：<span class="text-secondary">` + e.dno + `</span>
									<i class="bi bi-share ms-2"></i>
								</p>
								<p class="my-1">维修日期：<span class="text-warning">` + E.timestampToDate(e.date) + `</span></p>
								<p class="my-1">故障位置：<span class="text-dark">` + e.address + `</span></p>
								<p class="my-1">联系电话：<span class="text-dark">` + e.lxrphone + `</span>
									<i class="bi bi-telephone ms-2"></i>
								</p>
								<p class="my-1">故障描述：<span class="text-dark">` + e.description + `</span></p>
								<p class="my-1">维修人员：<span class="text-dark">` + e.wname + `</span></p>
								
								<div class="mt-2 text-end">
									<button class="btn btn-outline-secondary btn-sm">查看订单</button>
								</div>
							</div>
							    `)
							_tds.click(function() {
								location.href = "YYXXDZF.html?did=" + e.id;
							})
							_tbody.append(_tds);
						}


					});
				}
			}
		});
	},
	timestampToDate(timestamp) {
		const date = new Date(timestamp); // 将时间戳转换为Date对象
		const options = {
			year: 'numeric',
			month: 'long',
			day: 'numeric'
		}; // 定义日期格式
		return new Intl.DateTimeFormat('zh-CN', options).format(date); // 使用Intl.DateTimeFormat进行格式化
	}

}
$(function() {
	E.page();
})